@layout("/common/_container.html"){
<style>
    ul{padding: 0;}  .ulBox>li{margin: 10px 0;}
    #calendar .fc-center h2 {  border: 1px solid #A9A9A9;  margin: 0; padding: 5px 40px;  }
    #calendar .fc-center button {  background: white;  border-radius: 0;  border: 1px solid #a9a9a9; height: 38px; }
    #calendar .fc-center button:first-of-type {  border-right: none;  border-top-left-radius: 4px;;  border-bottom-left-radius: 4px;  }
    #calendar .fc-center button:last-of-type {  border-left: none;  margin: 0;  border-top-right-radius: 4px;;  border-bottom-right-radius: 4px;  }
    #calendar table table th {  line-height: 36px;  }   #calendar .fc-toolbar{margin-bottom: 10px;}
    #statePrompting{position: fixed;bottom: 0;height: 36px;background: white;z-index: 9;width: 100%;line-height: 36px;}
    #statePrompting .state{display: inline-block;width: 15px;height: 15px;flex: 1;margin:0 5px 0 15px;vertical-align: middle}
    .btnBox>button{border:1px solid #cccccc;border-radius: 4px;background: white;color: #333333;margin-bottom: 10px;}
    .ulBox>li span:first-of-type{ color: #666666; display: inline-block ;width: 120px;text-align: right;margin-right: 10px;font-size: 18px;}
    #calendar .fc-time-grid .fc-slats td {height: 0.9em}
</style>

<div style="display: none">
    <input type="hidden" id="doctorId" value="${id}">
    <input type="hidden" id="doctorName" value="${doctorName}">
</div>

<div class="ibox float-e-margins ">
    <div class="ibox-content record_box">
        <div style="position: absolute;right: 85px;top:15px;">
            <button class="btn" onclick="returnView()" type="button" style="border: 1px solid #cccccc;background: white;outline:none">返回诊所视图</button>
            <button class="btn" onclick="btnRefetchEvents()" type="button" style="border: 1px solid #cccccc;background: white;outline:none"><span class="glyphicon glyphicon-refresh" style="vertical-align: middle;margin-bottom: 4px;"></span></button>
        </div>

        <div id='calendar' style="margin-bottom: 16px;"></div>
    </div>
    <div id="statePrompting" class="clearfix">
        <div style="float: right;width:450px;display: flex">
            <div><span class="state" style="background: #1E90FF"></span>预约</div>
            <div><span class="state" style="background: #0e4c98"></span>挂号</div>
            <div><span class="state" style="background: #789cdc"></span>确认</div>
            <div><span class="state" style="background: #ffa800"></span>治疗中</div>
            <div><span class="state" style="background: #2dc87e"></span>治疗完成</div>
            <div><span class="state" style="background: #87d127"></span>离开</div>
            <div><span class="state" style="background: #808080"></span>失约</div>
        </div>
    </div>
</div>


<link rel="stylesheet" href="${ctxPath}/static/modular/fullcalendar/fullcalendar.css">
<link href='${ctxPath}/static/modular/fullcalendar//fullcalendar.print.min.css' rel='stylesheet' media='print'/>
<script src="${ctxPath}/static/modular/fullcalendar/lib/moment.min.js"></script>
<script src="${ctxPath}/static/modular/fullcalendar/lib/jquery.min.js"></script>
<script src="${ctxPath}/static/modular/fullcalendar/lib/jquery-ui.min.js"></script>
<script src="${ctxPath}/static/modular/fullcalendar/fullcalendar.js"></script>
<script src="${ctxPath}/static/modular/fullcalendar/scheduler.min.js"></script>
<script src="${ctxPath}/static/modular/fullcalendar/locale/zh-cn.js"></script>
<script src="${ctxPath}/static/modular/arrival/customer/customer_reservationViews.js"></script>

<script>
    $(function () {
        $('#calendar').fullCalendar({
            header: {
                left: 'agendaDay,agendaWeek',
                center: 'prev title next',
                right: 'today'
            },
            views: {
                agendaDay: {
                    groupByResource: true
                }
            },
            resources: [], droppable: true, defaultView: 'agendaWeek', allDaySlot: false, navLinks: true,
            selectable: true, selectHelper: true, editable: true, eventLimit: true, lazyFetching: true,
            handleWindowResize:true, nowIndicator: true, titleFormat: 'YYYY-MM-DD', minTime: "08:00:00",
            maxTime: "18:00:00", height:window.innerHeight-52, slotDuration: "00:15:00", slotLabelFormat: 'HH:mm',
            selectMinDistance: 30, timeFormat: 'H:mm', slotEventOverlap: false, slotLabelInterval: "00:30:00", schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
            dragRevertDuration: 200, unselectAuto: false, groupByResource: false, groupByDateAndResource: false,
            windowResize: function(view) {$('#calendar').fullCalendar('option', 'height', window.innerHeight-52);},
            select: function (startDate, endDate, jsEvent, view, resource) {
                var start = startDate.format('YYYY-MM-DD HH:mm');
                var end = endDate.format('YYYY-MM-DD HH:mm');
                var start1 = new Date(start);
                var end1 = new Date(end);
                var continued = parseInt(end1 - start1)/1000/60;
                var docName;
                if (view.type == 'agendaDay') {
                    docName = resource.title;
                } else {
                    docName = '';
                }
                if(docName != ''){
                    var eventData = start + "," + end + "," + docName + "," + continued;
                    var index = layer.open({
                        type: 2,
                        title: '添加预约客户',
                        area: ['60%', '90%'], //宽高
                        fix: true, //不固定
                        maxmin: true,
                        content: Feng.ctxPath + '/doctorLooked/doctor_addTask/' + eventData
                    });
                    this.layerIndex = index;
                }
                $('#calendar').fullCalendar('unselect');
            },
            events:function (start,end,timezone, callback) {
                var startTime = start.format('YYYY-MM-DD HH:mm:ss');
                var ends = new Date(end.format('YYYY-MM-DD HH:mm:ss'));
                var YY = ends.getFullYear();
                var MM = ends.getMonth() + 1;
                var DD = ends.getDate() - 1;
                if(MM < 10 ){MM = "0" + MM}else if(DD < 10 ){DD = "0" + DD}
                var endTime = YY + "-" + MM + "-" + DD + " " + "23:59:59";
                console.log(startTime);
                console.log(endTime);
                var doctorId = $("#doctorId").val();
                var doctorName = $("#doctorName").val();
                var timeSlot = startTime + "," + endTime +"," + doctorId;
                $.ajax({
                    url: Feng.ctxPath +'/doctorLooked/getDataDoctor/' + timeSlot,
                    dataType:'json',
                    type: 'POST',
                    success:function(data) {
                        console.log(data);
                        var events =[];
                        $.each(data,function (key,value) {
                            var obj =  {
                                id: value.customerId,
                                title: value.appointmentPayService ,
                                start: new Date(Date.parse(value.startTime)),
                                end: new Date(Date.parse(value.endTime)),
                                customerName: value.customerName,
                                resourceId:value.id,
                                medicalRecordNumber:value.medicalRecordNumber,
                                customerPhone:value.customerPhone,
                                customerAge:value.customerAge,
                                doctor:value.doctor,
                                arrivalStore:value.arrivalStore,
                                fieldTc:value.fieldTc,
                                remarks:value.remarks,
                                firstVisitDate:value.firstVisitDate,
                                filingTime:value.filingTime,
                                archiving:value.archiving,
                                birthday:value.birthday,
                                createAppointmentTime:value.createAppointmentTime,
                                arrivalStatus:value.arrivalStatus,
                                customerStatus:value.customerStatus,
                                reservationsId:value.reservationsId,
                                accountarrears:value.accountarrears,
                                yellowNumber:value.yellowNumber
                            };
                            if(value.arrivalStatus == '1'){
                                obj.backgroundColor = "#1E90FF";
                                obj.borderColor = "#1E90FF";
                            }else if(value.arrivalStatus == '2'){
                                obj.backgroundColor = "#0e4c98";
                                obj.borderColor = "#0e4c98";
                            }else if(value.arrivalStatus == '3'){
                                obj.backgroundColor = "#ffa800";
                                obj.borderColor = "#ffa800";
                            }else if(value.arrivalStatus == '4'){
                                obj.backgroundColor = "#2dc87e";
                                obj.borderColor = "#2dc87e";
                            }else if(value.arrivalStatus == '5'){
                                obj.backgroundColor = "#87d127";
                                obj.borderColor = "#87d127";
                            }else if(value.arrivalStatus == '6'){
                                obj.backgroundColor = "#789cdc";
                                obj.borderColor = "#789cdc";
                            }else if(value.arrivalStatus == '7'){
                                obj.backgroundColor = "#808080";
                                obj.borderColor = "#808080";
                            }
                            events.push(obj)
                        });
                        callback(events);
                    }
                });

                $('#calendar').fullCalendar('addResource', {
                    id:doctorId,
                    title:doctorName
                });
            },
            eventClick: function(calEvent, jsEvent, view){
                var start = calEvent.start.format('YYYY-MM-DD');
                var starts = calEvent.start.format('HH:mm');
                var end = calEvent.end.format('HH:mm');
                console.log(calEvent);
                jsEvent.stopPropagation();
                $(this).attr('id',calEvent.id);

                var eds =
                    '<div style="color: #555555;padding-top: 8px;">' +
                    '<div><span style="color: #319dbc;font-size: 21px;font-weight: bold;padding-left: 15px;cursor:pointer;" onclick="openBilee('+"'"+calEvent.id+"'"+')">'+calEvent.customerName+'</span>' +
                    '<span style="font-size: 18px;font-weight: 200;margin: 0 15px;">'+calEvent.arrivalStore+'</span><span style="font-size: 18px;font-weight: 200;">'+calEvent.customerStatus+'</span></div>' +
                    '<div style="padding: 3px 15px;"><span>'+calEvent.medicalRecordNumber+'</span></div>' +
                    '<div style="padding: 3px  15px;"><span>'+calEvent.customerPhone+'</span></div>' +
                    '<div style="padding: 3px  15px;"><span>'+start+'('+calEvent.doctor+')</span></div>' +
                    '<div style="color: #319DB5;padding:  3px 0"><span>今日预约【<span>0</span>】</span><span>之后预约【<span>0</span>】</span><span>之前预约【<span>0</span>】</span></div>' +
                    '<div style="padding: 10px 0 15px;border-top: 1px solid #cccccc">' +
                    '<ul class="ulBox">' +
                    '<li><span>预约时间</span><span style="color: black;font-weight: bold;font-size: 24px;">'+starts+'-'+end+'</span></li>' +
                    '<li><span>咨询师</span><span>'+calEvent.fieldTc+'</span></li>' +
                    '<li><span>预约医生</span><span>'+calEvent.doctor+'</span></li>' +
                    '<li><span>预约项目</span><span>'+calEvent.title+'</span></li>' +
                    '<li style="vertical-align:middle;"><span>预约备注</span><span style="display: inline-block;">'+calEvent.remarks+'</span></li>' +
                    '<li><span>初诊日期</span><span>'+calEvent.firstVisitDate+'</span></li>' +
                    '<li><span>创建时间</span><span>'+calEvent.createAppointmentTime+'</span></li>' +
                    '<li><span>创建人</span><span>'+calEvent.archiving+'</span></li>' +
                    '<li><span>黄页编号</span><span style="display: inline-block;width: 100px;">'+calEvent.yellowNumber+'</span><a style="color: brown" href="javascript:;" onclick="numberedModification('+"'"+calEvent.id+"','"+calEvent.yellowNumber+"'"+')">修改</a></li>' +
                    '</ul>' +
                    '</div>' +
                    '</div>';

                var ads1 =
                    '<div class="btnBox"><p class="btnBox" style="padding: 0;">' +
                    '<button type="button" class="btn" onclick="modifyAppointment('+"'"+calEvent.id+"'"+')">修改</button> ' +
                    '<button type="button" class="btn" onclick="registerAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">挂号</button> ' +
                    '<button type="button" class="btn" onclick="sureAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">确定</button> ' +
                    '<button type="button" class="btn" onclick="cancelAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">取消</button> ' +
                    '<button type="button" class="btn" onclick="appointment('+"'"+calEvent.id+"','"+calEvent.reservationsId+"','"+calEvent.doctor+"'"+')">再预约</button></p> ' +
                    '<button type="button" class="btn" onclick="printingAppointment('+"'"+calEvent.id+"'"+')">打印</button> ' +
                    '<button type="button" class="btn" onclick="shortMessage('+"'"+calEvent.id+"'"+')">短信</button> ' +
                    '</div>';

                var ads2 =
                    '<div class="btnBox">' +
                    '<button type="button" class="btn" onclick="modifyAppointment('+"'"+calEvent.id+"'"+')">修改</button> ' +
                    '<div class="btn-group dropup" style="display: inline-block;border: 1px solid #cccccc;border-radius:4px;">' +
                    '<button type="button" style="background: white;color: #333333;width: 100px;padding: 4px;border-right: 1px solid #cccccc;" class="btn" id="showTxt" onclick="startTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">开始治疗</button>' +
                    '<button type="button" style="background: white;color: #333333;width: 26px;padding: 4px;border-left: 1px solid #cccccc;" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
                    '<span class="caret"></span><span class="sr-only">Toggle Dropdown</span></button>' +
                    '<ul class="dropdown-menu" style="color: #333333;min-width: 100%;border: 1px solid #cccccc;text-align: center">' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="registerAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">挂号</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="startTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">开始治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="completionTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">完成治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="alreadyLeave('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">已离开</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="fallbackAction('+"'"+calEvent.id+"','"+calEvent.customerName+"','"+calEvent.arrivalStatus+"'"+')">回退</li></ul>' +
                    '</div> '+
                    '<button type="button" class="btn" onclick="appointment('+"'"+calEvent.id+"','"+calEvent.reservationsId+"','"+calEvent.doctor+"'"+')">再预约</button> ' +
                    '<button type="button" class="btn" onclick="printingAppointment('+"'"+calEvent.id+"'"+')">打印</button> ' +
                    '<button type="button" class="btn" onclick="shortMessage('+"'"+calEvent.id+"'"+')">短信</button> ' +
                    '</div>';

                var ads3 =
                    '<div class="btnBox">' +
                    '<button type="button" class="btn" onclick="modifyAppointment('+"'"+calEvent.id+"'"+')">修改</button> ' +
                    '<div class="btn-group dropup" style="display: inline-block;border: 1px solid #cccccc;border-radius:4px;">' +
                    '<button type="button" style="background: white;color: #333333;width: 100px;padding: 4px;border-right: 1px solid #cccccc;" class="btn" id="showTxt" onclick="completionTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">完成治疗</button>' +
                    '<button type="button" style="background: white;color: #333333;width: 26px;padding: 4px;border-left: 1px solid #cccccc;" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
                    '<span class="caret"></span><span class="sr-only">Toggle Dropdown</span></button>' +
                    '<ul class="dropdown-menu" style="color: #333333;min-width: 100%;border: 1px solid #cccccc;text-align: center">' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="registerAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">挂号</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="startTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">开始治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="completionTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">完成治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="alreadyLeave('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">已离开</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="fallbackAction('+"'"+calEvent.id+"','"+calEvent.customerName+"','"+calEvent.arrivalStatus+"'"+')">回退</li></ul>' +
                    '</div> '+
                    '<button type="button" class="btn" onclick="appointment('+"'"+calEvent.id+"','"+calEvent.reservationsId+"','"+calEvent.doctor+"'"+')">再预约</button> ' +
                    '<button type="button" class="btn" onclick="printingAppointment('+"'"+calEvent.id+"'"+')">打印</button> ' +
                    '<button type="button" class="btn" onclick="shortMessage('+"'"+calEvent.id+"'"+')">短信</button> ' +
                    '</div>';

                var ads4 =
                    '<div class="btnBox">' +
                    '<button type="button" class="btn" onclick="modifyAppointment('+"'"+calEvent.id+"'"+')">修改</button> ' +
                    '<div class="btn-group dropup" style="display: inline-block;border: 1px solid #cccccc;border-radius:4px;">' +
                    '<button type="button" style="background: white;color: #333333;width: 100px;padding: 4px;border-right: 1px solid #cccccc;" class="btn" id="showTxt" onclick="alreadyLeave('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">已离开</button>' +
                    '<button type="button" style="background: white;color: #333333;width: 26px;padding: 4px;border-left: 1px solid #cccccc;" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
                    '<span class="caret"></span><span class="sr-only">Toggle Dropdown</span></button>' +
                    '<ul class="dropdown-menu" style="color: #333333;min-width: 100%;border: 1px solid #cccccc;text-align: center">' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="registerAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">挂号</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="startTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">开始治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="completionTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">完成治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="alreadyLeave('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">已离开</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="fallbackAction('+"'"+calEvent.id+"','"+calEvent.customerName+"','"+calEvent.arrivalStatus+"'"+')">回退</li></ul>' +
                    '</div> '+
                    '<button type="button" class="btn" onclick="appointment('+"'"+calEvent.id+"','"+calEvent.reservationsId+"','"+calEvent.doctor+"'"+')">再预约</button> ' +
                    '<button type="button" class="btn" onclick="printingAppointment('+"'"+calEvent.id+"'"+')">打印</button> ' +
                    '<button type="button" class="btn" onclick="shortMessage('+"'"+calEvent.id+"'"+')">短信</button> ' +
                    '</div>';

                var ads5 =
                    '<div class="btnBox">' +
                    '<button type="button" class="btn" onclick="modifyAppointment('+"'"+calEvent.id+"'"+')">修改</button> ' +
                    '<div class="btn-group dropup" style="display: inline-block;border: 1px solid #cccccc;border-radius:4px;">' +
                    '<button type="button" style="background: #F2F2F2;color: #333333;width: 100px;padding: 4px;border-right: 1px solid #cccccc;pointer-events: none;" class="btn" id="showTxt">已离开</button>' +
                    '<button type="button" style="background: white;color: #333333;width: 26px;padding: 4px;border-left: 1px solid #cccccc;" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
                    '<span class="caret"></span><span class="sr-only">Toggle Dropdown</span></button>' +
                    '<ul class="dropdown-menu" style="color: #333333;min-width: 100%;border: 1px solid #cccccc;text-align: center">' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="registerAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">挂号</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="startTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">开始治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="completionTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">完成治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="alreadyLeave('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+')">已离开</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="fallbackAction('+"'"+calEvent.id+"','"+calEvent.customerName+"','"+calEvent.arrivalStatus+"'"+')">回退</li></ul>' +
                    '</div> '+
                    '<button type="button" class="btn" onclick="appointment('+"'"+calEvent.id+"','"+calEvent.reservationsId+"','"+calEvent.doctor+"'"+')">再预约</button> ' +
                    '<button type="button" class="btn" onclick="printingAppointment('+"'"+calEvent.id+"'"+')">打印</button> ' +
                    '<button type="button" class="btn" onclick="shortMessage('+"'"+calEvent.id+"'"+')">短信</button> ' +
                    '</div>';

                var ads6 =
                    '<div class="btnBox">' +
                    '<button type="button" class="btn" onclick="modifyAppointment('+"'"+calEvent.id+"'"+')">修改</button> ' +
                    '<button type="button" class="btn" onclick="appointment('+"'"+calEvent.id+"','"+calEvent.reservationsId+"','"+calEvent.doctor+"'"+')">再预约</button> ' +
                    '<button type="button" class="btn" onclick="printingAppointment('+"'"+calEvent.id+"'"+')">打印</button> ' +
                    '<button type="button" class="btn" onclick="shortMessage('+"'"+calEvent.id+"'"+')">短信</button> ' +
                    '</div>';

                if(calEvent.arrivalStatus == '1'||calEvent.arrivalStatus == '6'){
                    test = layer.open({
                        type:4,
                        tips:[2,'#ffffff'],
                        closeBtn:0,
                        area:['auto','auto'],
                        content:['<div>'+eds+''+ads1+'</div>','#'+calEvent.id+'']
                    });
                }else if(calEvent.arrivalStatus == '2'){
                    test = layer.open({
                        type:4,
                        tips:[2,'#ffffff'],
                        closeBtn:0,
                        area:['auto','auto'],
                        content:['<div>'+eds+''+ads2+'</div>','#'+calEvent.id+'']
                    });
                }else if(calEvent.arrivalStatus == '3'){
                    test = layer.open({
                        type:4,
                        tips:[2,'#ffffff'],
                        closeBtn:0,
                        area:['auto','auto'],
                        content:['<div>'+eds+''+ads3+'</div>','#'+calEvent.id+'']
                    });
                }else if(calEvent.arrivalStatus == '4'){
                    test = layer.open({
                        type:4,
                        tips:[2,'#ffffff'],
                        closeBtn:0,
                        area:['auto','auto'],
                        content:['<div>'+eds+''+ads4+'</div>','#'+calEvent.id+'']
                    });
                }else if(calEvent.arrivalStatus == '5'){
                    test = layer.open({
                        type:4,
                        tips:[2,'#ffffff'],
                        closeBtn:0,
                        area:['auto','auto'],
                        content:['<div>'+eds+''+ads5+'</div>','#'+calEvent.id+'']
                    });
                }else if(calEvent.arrivalStatus == '7'){
                    test = layer.open({
                        type:4,
                        tips:[2,'#ffffff'],
                        closeBtn:0,
                        area:['auto','auto'],
                        content:['<div>'+eds+''+ads6+'</div>','#'+calEvent.id+'']
                    });
                }
            },
            eventRender: function (calEvent,element, view) {//在呈现事件时触发
                var data1 = calEvent.end._d;
                var data2 = calEvent.start._d;
                var data3 = parseInt(data1 - data2) / 1000 / 60;
                if(calEvent.customerName == ""||calEvent.customerName == null){
                    element.prepend("<div class='myfc-title'><span>新建预约</span></div>");
                }else {
                    if(calEvent.accountarrears != 0){
                        if(data3 < 60){
                            element.prepend("<div class='myfc-title'><span style='font-size: 18px;font-weight: bold'>"+calEvent.customerName+"</span></div>" +
                                "<div style='position: absolute;right: 5px;top: 5px;color: white;background: red;padding: 2px 2px 2px 5px;border: 1px solid #333333;font-weight: bold;border-radius: 5px;'>欠</div>");
                        }else {
                            element.prepend("<div class='myfc-title'><span style='font-size: 18px;font-weight: bold'>"+calEvent.customerName+"</span></div><div style='position: absolute;bottom: 5px;'>"+calEvent.remarks+"</div>" +
                                "<div style='position: absolute;right: 5px;top: 5px;color: white;background: red;padding: 2px 2px 2px 5px;border: 1px solid #333333;font-weight: bold;border-radius: 5px;'>欠</div>");
                        }
                    }else {
                        if(data3 < 60){
                            element.prepend("<div class='myfc-title'><span style='font-size: 18px;font-weight: bold'>"+calEvent.customerName+"</span></div>");
                        }else {
                            element.prepend("<div class='myfc-title'><span style='font-size: 18px;font-weight: bold'>"+calEvent.customerName+"</span></div><div style='position: absolute;bottom: 5px;'>"+calEvent.remarks+"</div>");
                        }
                    }
                }
            },
            //拖拽到其它地方
            eventDrop:function (event, delta, revertFunc, jsEvent, ui, view) {
                if(event.arrivalStatus == '5'||event.arrivalStatus == '7'){
                    alert("已经离开的预约不能修改！")
                    revertFunc()
                }else {
                    if(confirm("您确定要修改预约么？")) {
                        var startTime = event.start.format('YYYY-MM-DD HH:mm:ss');
                        var endTime = event.end.format('YYYY-MM-DD HH:mm:ss');
                        var doctorId = event.resourceId;
                        var id = event.id;
                        var sed = startTime + "," + endTime + "," + doctorId + "," + id;

                        $.ajax({
                            url: Feng.ctxPath + '/doctorLooked/draftingUpdate/' + sed,
                            dataType: 'json',
                            type: 'POST',
                            success: function (data) {
                                alert('修改成功!');
                                window.$('#calendar').fullCalendar('refetchEvents');
                            },
                            error:function (data) {
                                revertFunc()
                            }
                        });
                    }else {
                        revertFunc()
                    }
                }
            },
            //往下拖框
            eventResize:function (event, delta, revertFunc, jsEvent, ui, view) {
                if(event.arrivalStatus == '5'||event.arrivalStatus == '7'){
                    alert("已经离开的预约不能修改！")
                    revertFunc()
                }else {
                    if(confirm("您确定要修改预约么？")) {
                        var startTime = event.start.format('YYYY-MM-DD HH:mm:ss');
                        var endTime = event.end.format('YYYY-MM-DD HH:mm:ss');
                        var doctorId = event.resourceId;
                        var id = event.id;
                        var sed = startTime + "," + endTime + "," + doctorId + "," + id;
                        $.ajax({
                            url: Feng.ctxPath + '/doctorLooked/draftingUpdate/' + sed,
                            dataType: 'json',
                            type: 'POST',
                            success: function (data) {
                                alert('修改成功!');
                                window.$('#calendar').fullCalendar('refetchEvents');
                            },
                            error:function (data) {
                                revertFunc()
                            }
                        });
                    }else {
                        revertFunc()
                    }
                }
            }
        })
        $("#calendar").on('click','h2',function () {
            laydate({
                istime: true,
                format: 'YYYY-MM-DD',
                choose:function (value) {
                    $('#calendar').fullCalendar( 'gotoDate', value )
                }
            })
        })
    });
    /**
     * 返回诊所视图
     */
    returnView = function () {
        window.location = "${ctxPath}/customer/customer_reservationViews"
    };
</script>

@}
